package com.example.arithmeticleetcode.leetcode.dec;

import java.util.Arrays;

/**
 * @program: arithmetic-leetcode
 * @description:
 * @author: FangZhen
 * @create: 2020-12-18 09:21
 **/
public class Demo17 {

    public static void main(String[] args) {
        System.out.println(numSteps("1101"));
        System.out.println(numSteps("10"));
        System.out.println(numSteps("1111011110000011100000110001011011110010111001010111110001"));
    }

    public static int numSteps(String s) {
        int len = s.length() - 1;
        while (len >= 0 && s.charAt(len) == '0') len--;
        if (len == 0) return s.length() - 1;
        int zero = 0;
        while (len > 0) if (s.charAt(len) == '0') zero++;
        return zero + s.length() + 1;
    }
}
